package com.example.score.controller;

import com.example.score.common.Result;
import com.example.score.service.TeacherStarStudentService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/t_star_s")
@RequiredArgsConstructor
public class TeacherStarStudentController {

    @Autowired
    private TeacherStarStudentService teacherStarStudentService;

    /**
     * 收藏学生
     */
    @GetMapping("/star")
    public Result<?> star(
            @RequestParam Long teacherId,
            @RequestParam Long studentId) {
        teacherStarStudentService.star(teacherId,studentId);
        return Result.success(true);
    }

    /**
     * 取消收藏学生
     */
    @GetMapping("/unStar")
    public Result<?> unStar(
            @RequestParam Long teacherId,
            @RequestParam Long studentId) {
        teacherStarStudentService.unStar(teacherId,studentId);
        return Result.success(true);
    }

    /**
     * 获取收藏学生列表
     */
    @GetMapping("/starList")
    public Result<List<Long>> starList(
            @RequestParam Long teacherId) {
        List<Long> studentIds = teacherStarStudentService.starList(teacherId);
        return Result.success(studentIds);
    }
}
